//API进行统一管理
import requests from './ajax'
import mockRequests from './mockAjax'

//三级联动接口
//  /api/product/getBaseCategoryList  get 无参数
//axios发请求返回的是一个Promise对象

//不能用.get方法，只能写在对象里
//三级联动接口
export const reqCategoryList = () => requests({ url: '/product/getBaseCategoryList', method: 'get' })
//Banner接口，ListContainer组件
export const reqGetBannerList = () => mockRequests.get('/banner');
//Floor接口
export const reqGetFloorList = () => mockRequests({ url: '/floor', method: 'get' });
//Search接口 /api/list post 有参数
/* 
    {
        "category3Id": "61",
        "categoryName": "手机",
        "keyword": "小米",
        "order": "1:desc",
        "pageNo": 1,
        "pageSize": 10,
        "props": ["1:1700-2799:价格", "2:6.65-6.74英寸:屏幕尺寸"],
        "trademark": "4:小米"
    }

*/
export const reqGetSearchInfo = (params) => requests({ url: '/list', method: 'post',data: params })
//产品详情接口Detail  /api/item/{skuId} get
export const reqGetDetailInfo = (skuId) => requests({ url: `/item/${skuId}`, method: 'get' })
//添加到购物车（或者更新某个产品的个数） /api/cart/addToCart/{ skuId }/{ skuNum } post
export const reqAddOrUpdateShopCart = (skuId,skuNum) =>requests({ url: `/cart/addToCart/${ skuId }/${ skuNum }`, method: 'post' })
//获取购物车数据   /api/cart/cartList  get
export const reqShopCartList = () => requests.get('/cart/cartList')
//删除购物车产品数据   /api/cart/deleteCart/{skuId}
export const reqDeleteCart = (skuId) => requests({url:`/cart/deleteCart/${skuId}`,method:'delete'})
//修改商品选中状态 /api/cart/checkCart/{skuId}/{isChecked} get
export const reqUpdateChecked = (skuId,isChecked) => requests({url:`/cart/checkCart/${skuId}/${isChecked}`,method:'get'})
//获取验证码 /api/user/passport/sendCode/{phone} get
export const reqGetCode = (phone) => requests({url:`/user/passport/sendCode/${phone}`,method:'get'})
//完成注册 /api/user/passport/register post
export const reqUserRegister = (data) => requests({url:'/user/passport/register',method:'post',data})
//登录 /api/user/passport/login post phone,password
export const reqUserLogin = (data) => requests({url:'/user/passport/login',method:'post',data})
//展示用户信息     /api/user/passport/auth/getUserInfo get
export const reqUserInfo = () => requests({url:'/user/passport/auth/getUserInfo',method:'get'})
//退出登录   /api/user/passport/logout  get
export const reqLogout = () => requests({url:'/user/passport/logout',method:'get'})
//获取用户地址信息  /api/user/userAddress/auth/findUserAddressList  get
export const reqAddressInfo = () => requests({url:'/user/userAddress/auth/findUserAddressList',method:'get'})
//获取商品清淡  /api/order/auth/trade get
export const reqOrderInfo = () => requests({url:'/order/auth/trade',method:'get'})
//提交订单   /api/order/auth/submitOrder?tradeNo={tradeNo} post data
/* 例子
    {
    "consignee": "admin",
    "consigneeTel": "15011111111",
    "deliveryAddress": "北京市昌平区2",
    "paymentWay": "ONLINE",
    "orderComment": "xxx",
    "orderDetailList": [
        {
            "id": null,
            "orderId": null,
            "skuId": 6,
            "skuName": " Apple iPhone 11 (A2223) 128GB 红色 移动联通电信22",
            "imgUrl": "http://182.92.128.115:8080//rBFUDF6V0JmAG9XGAAGL4LZv5fQ163.png",
            "orderPrice": 4343,
            "skuNum": 2,
            "hasStock": null
        },

*/
export const reqSubmitOrder = (tradeNo,data) => requests({url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,method:'post',data})
//获取订单支付信息  /api/payment/weixin/createNative/{orderId}  get
export const reqPayInfo = (orderId) => requests({url:`/payment/weixin/createNative/${orderId}`,method:'get'})
//获取支付状态   /api/payment/weixin/queryPayStatus/{orderId} get
export const reqPayStatus = (orderId) => requests({url:`/payment/weixin/queryPayStatus/${orderId}`,method:'get'})
//获取个人中心的数据  /api/order/auth/{page}/{limit} get
export const reqMyOrderList = (page,limit) => requests({url:`/order/auth/${page}/${limit}`,method:'get'})
